
package com.sskj.jkzx.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sskj.jkzx.domain.entity.basic.BasicAN;
import com.sskj.jkzx.domain.entity.basic.BasicKV;
import com.sskj.jkzx.domain.entity.quantity.EmpCreditQuantity;
import com.sskj.jkzx.domain.entity.quantity.EmpQuantity;
import com.sskj.jkzx.domain.entity.quantity.EmpTypeQuantity;
import com.sskj.jkzx.domain.entity.quantity.EngQuantity;
import com.sskj.jkzx.domain.entity.quantity.OrgCreditQuantity;
import com.sskj.jkzx.domain.entity.quantity.OrgQuantity;
import com.sskj.jkzx.domain.entity.quantity.OrgTypeQuantity;
import com.sskj.utils.HttpHelp;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "**/sskj/basic", method = { RequestMethod.POST, RequestMethod.GET })
@Api(value = "基础信息查询", description = "基础信息查询")
public class BasicInfoServiceImpl {

	protected final Log logger = LogFactory.getLog(BasicInfoServiceImpl.class);

	private final static String LABOR_API_PREFIX = "/labor";

	@Value("${sskj.elasticSearchServer}")
	private String elasticSearchServer;

	@Value("${sskj.laborServer}")
	private String laborServer;

	@Value("${sskj.fdfsService}")
	private String fdfsService;

	@Autowired
	QuantityServiceImpl quantityServiceImpl;

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/page", method = RequestMethod.GET)
	@ApiOperation(value = "查询人员的派工记录", httpMethod = "GET")
	public Object queryLaborPage(@RequestParam Map<String, Object> params) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/page";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/comment/page", method = RequestMethod.GET)
	@ApiOperation(value = "查询人员评价记录", httpMethod = "GET")
	public Object queryLaborCommentPage(@RequestParam Map<String, Object> params) throws Exception {
		String url = laborServer + LABOR_API_PREFIX + "/comment/page";
		String responseStr = HttpHelp.sendGet(url, params);
		JSONObject responseJson = JSON.parseObject(responseStr);
		return responseJson;
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/stbms/findByIdAndIdCardNumber", method = RequestMethod.GET)
	@ApiOperation(value = "通过培训记录id和省份证号查询培训人员考试记录", httpMethod = "GET")
	public Object queryLaborTrainEmpByPxjlIdAndIdCardNumber(String trainPlanRecordId, String idCardNumber) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/stbms/findByIdAndIdCardNumber?" + "id=" + trainPlanRecordId
					+ "&idCardNumber=" + idCardNumber;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/postWorker/byEngWorkerId", method = RequestMethod.GET)
	@ApiOperation(value = "岗位入场情况查询", httpMethod = "GET")
	public Object queryPostWorker(String engWorkerId) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/postWorker/byEngWorkerId?engWorkerId=" + engWorkerId;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/fdfs/doclink/findbyglid", method = RequestMethod.GET)
	@ApiOperation(value = "文件查询", httpMethod = "GET")
	public Object queryFileByGlid(String glid) {
		try {
			String url = fdfsService + "/doclink/findbyglid?glid=" + glid;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/workOrderPerson/count", method = RequestMethod.GET)
	@ApiOperation(value = "通过sgxkId查询派工记录全部劳务人员", httpMethod = "GET")
	public Object queryWorkOrderPersonCount(String sgxkId, Integer pageSize, Integer currentPage) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/workOrderPerson/count?siteId=" + sgxkId + "&limit="
					+ pageSize + "&page=" + currentPage;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/workOrderPerson/getList", method = RequestMethod.GET)
	@ApiOperation(value = "查询人员的派工记录", httpMethod = "GET")
	public Object queryWorkOrderPersonGetList(String personId) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/workOrderPerson/getList/" + personId;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/engWorker/attendance/page", method = RequestMethod.GET)
	@ApiOperation(value = "人员考勤记录分页查询", httpMethod = "GET")
	public Object queryEngWorkerAttendancePage(@RequestParam Map<String, Object> params) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/engWorker/attendance/page";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/attendance/page", method = RequestMethod.GET)
	@ApiOperation(value = "人员考勤记录分页查询", httpMethod = "GET")
	public Object queryAttendancePage(@RequestParam Map<String, Object> params) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/attendance/page";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/stbms/findTrainRecordByPerson", method = RequestMethod.GET)
	@ApiOperation(value = "通过人员查询培训记录", httpMethod = "GET")
	public Object queryTrainRecordByDepartId(@RequestParam Map<String, Object> params) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/stbms/findTrainRecordByPerson";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/wages/page", method = RequestMethod.GET)
	@ApiOperation(value = "工资发放查询", httpMethod = "GET")
	public Object queryWages(@RequestParam Map<String, Object> params) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/wages/page";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/engWorker/list", method = RequestMethod.GET)
	@ApiOperation(value = "派工入场人数统计", httpMethod = "GET")
	public Object queryEngWorkerList() {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/engWorker/list";
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/engWorker/page", method = RequestMethod.GET)
	@ApiOperation(value = "派工入场分页查询", httpMethod = "GET")
	public Object queryEngWorkerPage(Integer pageSize, Integer currentPage) {
		try {
			if (pageSize == null) {
				pageSize = 10;
			}
			if (currentPage == null) {
				currentPage = 0;
			} else {
				currentPage = currentPage < 0 ? 0 : currentPage;
			}
			String url = laborServer + LABOR_API_PREFIX + "/engWorker/page?" + "limit=" + pageSize + "&page="
					+ currentPage;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			return responseJson;
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/cio/credit_level", method = RequestMethod.GET)
	@ApiOperation(value = "根据诚信等级分页查询企业", httpMethod = "GET")
	public Object queryCioByCreditLevel(String creditLevel, Integer pageSize, Integer currentPage) {
		try {
			if (pageSize == null) {
				pageSize = 10;
			}
			if (currentPage == null) {
				currentPage = 0;
			} else {
				currentPage = currentPage < 0 ? 0 : currentPage;
			}
			String url = elasticSearchServer + "/api/search/ciocredit?" + "creditLevel=" + creditLevel
					+ "&pageSize=" + pageSize + "&currentPage=" + currentPage;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/person/credit_level", method = RequestMethod.GET)
	@ApiOperation(value = "根据诚信等级分页查询人员", httpMethod = "GET")
	public Object queryPersonByCreditLevel(String creditLevel, Integer pageSize, Integer currentPage) {
		try {
			if (pageSize == null) {
				pageSize = 10;
			}
			if (currentPage == null) {
				currentPage = 0;
			} else {
				currentPage = currentPage < 0 ? 0 : currentPage;
			}
			String url = elasticSearchServer + "/api/search/personcredit?" + "type=creditLevel" + "&tag="
					+ creditLevel + "&sort=creditScore&direction=DESC" + "&pageSize=" + pageSize + "&currentPage="
					+ currentPage;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	/***
	 * 企业/人员基础信息查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/oeq", method = RequestMethod.GET)
	@ApiOperation(value = "企业/人员基础信息查询", httpMethod = "GET")
	public Map<String, BasicAN> queryOrgAndEmplQuantity() {

		Map<String, BasicAN> result = new HashMap<String, BasicAN>();

		OrgQuantity orgqt;
		try {
			orgqt = quantityServiceImpl.orgqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			orgqt = null;
		}

		if (orgqt != null) {
			result.put("org", new BasicAN(Long.valueOf(orgqt.getTotal()), Long.valueOf(orgqt.getNewly())));
		} else {
			result.put("org", new BasicAN(0, 0));
		}

		EmpQuantity empqt;
		try {
			empqt = quantityServiceImpl.empqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			empqt = null;
		}

		if (empqt != null) {
			result.put("emp", new BasicAN(Long.valueOf(empqt.getTotal()), Long.valueOf(empqt.getNewly())));
		} else {
			result.put("emp", new BasicAN(0, 0));
		}

		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	/**
	 * 企业类型比例查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/oc", method = RequestMethod.GET)
	@ApiOperation(value = "企业类型比例查询", httpMethod = "GET")
	public Map<String, List<BasicKV>> queryOrgCategory() {

		Map<String, List<BasicKV>> result = new HashMap<String, List<BasicKV>>();
		// 企业资质数量
		List<BasicKV> kv1 = new ArrayList<BasicKV>();
		// 企业数量（本地/外地）
		List<BasicKV> kv2 = new ArrayList<BasicKV>();

		OrgTypeQuantity orgqtBd;
		try {
			orgqtBd = quantityServiceImpl.orgtypeqtByType("本地");
		} catch (Exception e) {
			logger.info(e.getMessage());
			orgqtBd = null;
		}

		if (orgqtBd != null) {
			kv1.add(new BasicKV("建设单位", Integer.toString(orgqtBd.getJsdw())));
			kv1.add(new BasicKV("施工单位", Integer.toString(orgqtBd.getSgdw())));
			kv1.add(new BasicKV("监理单位", Integer.toString(orgqtBd.getJldw())));
			kv1.add(new BasicKV("勘察设计", Integer.toString(orgqtBd.getKcdw())));
			kv1.add(new BasicKV("图审单位", Integer.toString(orgqtBd.getTsdw())));
			kv1.add(new BasicKV("检测机构", Integer.toString(orgqtBd.getJcdw())));
			kv2.add(new BasicKV("本地", Integer.toString(orgqtBd.getJsdw() + orgqtBd.getSgdw() + orgqtBd.getJldw()
					+ orgqtBd.getKcdw() + orgqtBd.getTsdw() + orgqtBd.getJcdw())));
		} else {
			kv1.add(new BasicKV("建设单位", "0"));
			kv1.add(new BasicKV("施工单位", "0"));
			kv1.add(new BasicKV("监理单位", "0"));
			kv1.add(new BasicKV("勘察设计", "0"));
			kv1.add(new BasicKV("图审单位", "0"));
			kv1.add(new BasicKV("检测机构", "0"));
			kv2.add(new BasicKV("本地", "0"));
		}

		OrgTypeQuantity orgqtWd;
		try {
			orgqtWd = quantityServiceImpl.orgtypeqtByType("外地");
		} catch (Exception e) {
			logger.info(e.getMessage());
			orgqtWd = null;
		}

		if (orgqtWd != null) {
			kv1.add(new BasicKV("建设单位", Integer.toString(orgqtWd.getJsdw())));
			kv1.add(new BasicKV("施工单位", Integer.toString(orgqtWd.getSgdw())));
			kv1.add(new BasicKV("监理单位", Integer.toString(orgqtWd.getJldw())));
			kv1.add(new BasicKV("勘察设计", Integer.toString(orgqtWd.getKcdw())));
			kv1.add(new BasicKV("图审单位", Integer.toString(orgqtWd.getTsdw())));
			kv1.add(new BasicKV("检测机构", Integer.toString(orgqtWd.getJcdw())));
			kv2.add(new BasicKV("外地", Integer.toString(orgqtWd.getJsdw() + orgqtWd.getSgdw() + orgqtWd.getJldw()
					+ orgqtWd.getKcdw() + orgqtWd.getTsdw() + orgqtWd.getJcdw())));
		} else {
			kv1.add(new BasicKV("建设单位", "0"));
			kv1.add(new BasicKV("施工单位", "0"));
			kv1.add(new BasicKV("监理单位", "0"));
			kv1.add(new BasicKV("勘察设计", "0"));
			kv1.add(new BasicKV("图审单位", "0"));
			kv1.add(new BasicKV("检测机构", "0"));
			kv2.add(new BasicKV("外地", "0"));
		}

		result.put("kv1", kv1);
		result.put("kv2", kv2);

		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	/**
	 * 招标中工程项目数量查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/gcec", method = RequestMethod.GET)
	@ApiOperation(value = "招标工程、在建工程、竣工工程数量查询", httpMethod = "GET")
	public List<BasicKV> queryZhaoBiaoEngCount() {

		List<BasicKV> result = new ArrayList<BasicKV>();

		EngQuantity engqt;
		try {
			engqt = quantityServiceImpl.engqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			engqt = null;
		}

		if (engqt != null) {
			result.add(new BasicKV("在建工程(全市)", engqt.getZbgc()));
			result.add(new BasicKV("在建工程(城区)", engqt.getJdzjgc()));
			result.add(new BasicKV("竣工工程(今年)", engqt.getJggc()));
		} else {
			result.add(new BasicKV("在建工程(全市)", "0"));
			result.add(new BasicKV("在建工程(城区)", "0"));
			result.add(new BasicKV("竣工工程(今年)", "0"));
		}
		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	/**
	 * 人员证书分类数据查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/pcc", method = RequestMethod.GET)
	@ApiOperation(value = "人员证书分类数据查询", httpMethod = "GET")
	public List<BasicKV> queryPersonalCertCategory() {

		List<BasicKV> result = new ArrayList<BasicKV>();

		EmpTypeQuantity empqt;
		try {
			empqt = quantityServiceImpl.emptypeqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			empqt = new EmpTypeQuantity();
		}

		result.add(new BasicKV("监理工程师(国家)", empqt.getV1()));
		result.add(new BasicKV("监理工程师(省)", empqt.getV2()));
		result.add(new BasicKV("造价师", empqt.getV3()));
		result.add(new BasicKV("建造师(一级)", empqt.getV4()));
		result.add(new BasicKV("建造师(二级)", empqt.getV5()));
		result.add(new BasicKV("岗位证书_安全员", empqt.getV6()));
		result.add(new BasicKV("岗位证书_材料员", empqt.getV7()));
		result.add(new BasicKV("岗位证书_施工员", empqt.getV8()));
		result.add(new BasicKV("岗位证书_造价员", empqt.getV9()));
		result.add(new BasicKV("岗位证书_监理员", empqt.getV10()));

		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	/**
	 * 人员证书分类数据查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/pccall", method = RequestMethod.GET)
	@ApiOperation(value = "人员证书分类数据查询（全部）", httpMethod = "GET")
	public List<BasicKV> queryPersonalCertCategoryAll() {

		List<BasicKV> result = new ArrayList<BasicKV>();

		EmpTypeQuantity empqt;
		try {
			empqt = quantityServiceImpl.emptypeqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			empqt = new EmpTypeQuantity();
		}

		result.add(new BasicKV("注册执业证书_注册监理工程师_国家级", empqt.getV1()));
		result.add(new BasicKV("注册执业证书_注册监理工程师_省级", empqt.getV2()));
		result.add(new BasicKV("注册执业证书_注册造价师", empqt.getV3()));
		result.add(new BasicKV("注册执业证书_注册建造师_一级", empqt.getV4()));
		result.add(new BasicKV("注册执业证书_注册建造师_二级", empqt.getV5()));
		result.add(new BasicKV("岗位证书_安全员", empqt.getV6()));
		result.add(new BasicKV("岗位证书_材料员", empqt.getV7()));
		result.add(new BasicKV("岗位证书_施工员", empqt.getV8()));
		result.add(new BasicKV("岗位证书_造价员", empqt.getV9()));
		result.add(new BasicKV("岗位证书_监理员", empqt.getV10()));

		result.add(new BasicKV("岗位证书_检测员", empqt.getV11()));
		result.add(new BasicKV("岗位证书岗位证书_工程管理", empqt.getV12()));
		result.add(new BasicKV("岗位证书_内审员", empqt.getV13()));
		result.add(new BasicKV("岗位证书_BIM建模师", empqt.getV14()));
		result.add(new BasicKV("特种设备人员作业证_压力容器作业证", empqt.getV15()));
		result.add(new BasicKV("特种设备人员作业证_建筑起重机械安装拆卸工", empqt.getV16()));
		result.add(new BasicKV("职称证书_高级工程师", empqt.getV17()));
		result.add(new BasicKV("职称证书_工程师", empqt.getV18()));
		result.add(new BasicKV("职称证书_助理工程师", empqt.getV19()));
		result.add(new BasicKV("职称证书_高级经济师", empqt.getV20()));
		result.add(new BasicKV("职称证书_经济师", empqt.getV21()));
		result.add(new BasicKV("职称证书_助理经济师", empqt.getV22()));
		result.add(new BasicKV("职称证书_高级统计师", empqt.getV23()));
		result.add(new BasicKV("职称证书_统计师", empqt.getV24()));
		result.add(new BasicKV("职称证书_统计员", empqt.getV25()));

		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	/**
	 * 企业信用评级数据查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/ocr", method = RequestMethod.GET)
	@ApiOperation(value = "企业信用评级数据查询", httpMethod = "GET")
	public List<BasicKV> queryOrgCreditRating() {

		List<BasicKV> result = new ArrayList<BasicKV>();

		OrgCreditQuantity orgcqt;
		try {
			orgcqt = quantityServiceImpl.orgcqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			orgcqt = null;
		}

		if (orgcqt != null) {
			result.add(new BasicKV("A级企业", orgcqt.getAj()));
			result.add(new BasicKV("B级企业", orgcqt.getBj()));
			result.add(new BasicKV("C级企业", orgcqt.getCj()));

		} else {
			result.add(new BasicKV("A级企业", "0"));
			result.add(new BasicKV("B级企业", "0"));
			result.add(new BasicKV("C级企业", "0"));
		}

		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	/**
	 * 个人信用评级数据查询
	 * 
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/pcr", method = RequestMethod.GET)
	@ApiOperation(value = "个人信用评级数据查询", httpMethod = "GET")
	public List<BasicKV> queryPersonalCreditRating() {

		List<BasicKV> result = new ArrayList<BasicKV>();

		EmpCreditQuantity empcqt;
		try {
			empcqt = quantityServiceImpl.empcqt();
		} catch (Exception e) {
			logger.info(e.getMessage());
			empcqt = null;
		}

		if (empcqt != null) {
			result.add(new BasicKV("A级个人", empcqt.getAj()));
			result.add(new BasicKV("B级个人", empcqt.getBj()));
			result.add(new BasicKV("C级个人", empcqt.getCj()));

		} else {
			result.add(new BasicKV("A级个人", "0"));
			result.add(new BasicKV("B级个人", "0"));
			result.add(new BasicKV("C级个人", "0"));
		}

		logger.info(JSONObject.toJSONString(result));
		return result;
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/map", method = RequestMethod.GET)
	@ApiOperation(value = "复工map search", httpMethod = "GET")
	public Object fgMapSearch() {
		try {
			String url = elasticSearchServer + "/api/search/fg/map";
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/canton/count", method = RequestMethod.GET)
	@ApiOperation(value = "返岗人员出发地分布（全国）", httpMethod = "GET")
	public Object fgFgrytj(String tag) {
		try {
			String url = elasticSearchServer + "/api/search/fg/canton/count?tag=" + tag;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/stage/count", method = RequestMethod.GET)
	@ApiOperation(value = "查询县市区项目复工审核各阶段的数量", httpMethod = "GET")
	public Object fgStageCount() {
		try {
			String url = elasticSearchServer + "/api/search/fg/stage/count";
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/engWorker/statistical/param", method = RequestMethod.GET)
	@ApiOperation(value = "劳务实名制统计查询", httpMethod = "GET")
	public Object engWorkerCtatistical(String param) {
		try {
			String url = laborServer + "/laboratt" + "/engWorker/statistical/param" + "?param=" + param;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/labor/count", method = RequestMethod.GET)
	@ApiOperation(value = "查询劳务人员数量统计", httpMethod = "GET")
	public Object fgLaborCount() {
		try {
			String url = elasticSearchServer + "/api/search/fg/labor/count";
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/xmry/count", method = RequestMethod.GET)
	@ApiOperation(value = "查询项目及人员复工数量", httpMethod = "GET")
	public Object fgCount() {
		try {
			String url = elasticSearchServer + "/api/search/fg/count";
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/stage/cio/count", method = RequestMethod.GET)
	@ApiOperation(value = "分页查询检测机构和商品砼已经审核通过可以开工的", httpMethod = "GET")
	public Object fgStageCioCount() {
		try {
			String url = elasticSearchServer + "/api/search/fg/stage/cio/list";
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/clock/count", method = RequestMethod.GET)
	@ApiOperation(value = "打卡人数查询", httpMethod = "GET")
	public Object fgClockCount(String date) {
		try {
			String url = elasticSearchServer + "/api/search/fg/clock/count?beginTime=" + date + "&endTime="
					+ date;
			String responseStr = HttpHelp.sendGet(url, null);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getBooleanValue("success")) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/stage/eng/page", method = RequestMethod.GET)
	@ApiOperation(value = "分页查询已经审核通过可以开工的", httpMethod = "GET")
	public Object fgEngPage(@RequestParam Map<String, Object> params) {
		try {
			String url = elasticSearchServer + "/api/search/fg/stage/eng/page";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getBooleanValue("success")) {
				return responseJson;
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/stage/cio/page", method = RequestMethod.GET)
	@ApiOperation(value = "分页查询检测机构和商品砼已经审核通过可以开工的", httpMethod = "GET")
	public Object fgStageCioPage(@RequestParam Map<String, Object> params) {
		try {
			String url = elasticSearchServer + "/api/search/fg/stage/cio/page";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getBooleanValue("success")) {
				return responseJson;
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/search/fg/stage/count/cio", method = RequestMethod.GET)
	@ApiOperation(value = "查询检测机构和商品砼的复工各阶段数据统计", httpMethod = "GET")
	public Object fgStageCioCount(@RequestParam Map<String, Object> params) {
		try {
			String url = elasticSearchServer + "/api/search/fg/stage/count/cio";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 * 实名制人员分页查询
	 * 
	 * @param params(selectType:
	 *            1代表总人数，2代表今日上报体温数，4代表今日新增数)
	 * @return
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/labor/person/pageIndex", method = RequestMethod.GET)
	@ApiOperation(value = "劳务实名制人员分页查询（总人数，今日上报体温数，今日新增数）", httpMethod = "GET")
	public Object laborPersonPage(@RequestParam Map<String, Object> params) {
		try {
			String url = laborServer + LABOR_API_PREFIX + "/person/pageIndex";
			String responseStr = HttpHelp.sendGet(url, params);
			JSONObject responseJson = JSON.parseObject(responseStr);
			if (responseJson.getInteger("code") == 0) {
				return responseJson.get("data");
			} else {
				return null;
			}
		} catch (Exception e) {
			return null;
		}
	}

}
